#include "CQuadTreePosItem.h"
#include "CQuadTreeNode.h"
#include "my_utilities/CRigidBody.h"
#include <iostream>
using namespace std;
/* ----------------------------------------------- */
/* --------------Start CQuadTreePosItem----------- */

CQuadTreePosItem::CQuadTreePosItem(CRigidBody* parent, Vec2f* p) :
    parent_(parent),
    pos_(p),
    node_(0)
{

}


CQuadTreePosItem::~CQuadTreePosItem() //dtor
{

}

//
//CQuadTreePosItem::CQuadTreePosItem(const CQuadTreePosItem& c) //copy ctor
//{
//
//}

//updates position for rectangle
void CQuadTreePosItem::Move()
{
    if (node_ == 0)
        assert(false);

    node_->ItemMove(this);
}

bool CQuadTreePosItem::operator==(const CQuadTreePosItem& n) const
{
    return ((n.parent_ == parent_) && (GetRect() == n.GetRect()));
}

CQuadTreePosItem& CQuadTreePosItem::operator=(const CQuadTreePosItem& c)
{
    if (this != &c)
    {
        this->parent_ = c.parent_;
        this->node_   = c.node_;
    }

    return *this;
}

//getters
Vec2f* CQuadTreePosItem::GetPos() const
{
    return pos_;
}


CRect CQuadTreePosItem::GetRect() const
{
    return parent_->GetBoundingRect();
}

CRigidBody* CQuadTreePosItem::GetParent() const
{
    return parent_;
}

CQuadTreeNode* CQuadTreePosItem::GetCurrentNode() const
{
    return node_;
}

void CQuadTreePosItem::SetCurrentNode(CQuadTreeNode* n)
{
    node_ = n;
}
/* --------End CQuadTreePosItem------------------- */
/* ----------------------------------------------- */
